//
//  UIButton-Extension.swift
//  weibo
//
//  Created by 叶子韬韬 on 2017/4/20.
//  Copyright © 2017年 叶子韬韬. All rights reserved.
//

import Foundation
import UIKit

extension UIButton{
    
    /*
    //swift 中类方法是一class开头的方法。类似OC中+开头的方法
    class func createButton(imageName:String,bgImageName:String)->UIButton {
        // 实现
        let btn = UIButton()
        //设置属性
        btn.setImage(UIImage(named:imageName), for: .normal)
        btn.setImage(UIImage(named:imageName+"_highlighted"), for: .highlighted)
        btn.setBackgroundImage(UIImage(named:bgImageName), for: .normal)
        btn.setBackgroundImage(UIImage(named:bgImageName+"_highlighted"), for: .highlighted)
        //设置尺寸根据图片自适应
        btn.sizeToFit()
        return btn
        
    }
 */
    
    convenience init (imageName:String,bgImageName:String){
        self.init()
        setImage(UIImage(named:imageName), for: .normal)
        setImage(UIImage(named:imageName+"_highlighted"), for: .highlighted)
        setBackgroundImage(UIImage(named:bgImageName), for: .normal)
        setBackgroundImage(UIImage(named:bgImageName+"_highlighted"), for: .highlighted)
        sizeToFit()
    }
    
    convenience init (backGroundColor:UIColor,font:UIFont,title:String){
        self.init()
        
        self.backgroundColor = backgroundColor
        self.titleLabel?.font = font
        setTitle(title, for: .normal)
        
    }
    
}
